﻿@model CNFM_CROCODILE_LOGO.Core.Domain.ViewModels.CrocodileUserModels

@{
    ViewData["Title"] = "企业开户EnterpriseAdd";
}

@section Scripts
    {
    <script type="text/javascript">
        var selfLayer = null, page = 1, active = null;
        layui.use(['form', 'layedit', 'treeSelect'], function () {
            var form = layui.form, treeSelect = layui.treeSelect; //表格

            //地区
            treeSelect.render({
                // 选择器
                elem: '#UnCode',
                // 数据
                data: '/User/GetAreaTreeAll?code=' + localStorage.getItem("X-AreCode"),
                // 请求头
                //  headers: { 'Authorization': 'Bearer ' + localStorage.getItem("X-TOKEN") },

                // 异步加载方式：get/post，默认get
                type: 'get',
                // 占位符
                placeholder: '地区',
                // 是否开启搜索功能：true/false，默认false
                search: true,
                // 一些可定制的样式
                style: {
                    folder: {
                        enable: true
                    },
                    line: {
                        enable: true
                    }
                },
                // 点击回调
                click: function (d) {
                    // console.log(d);
                },
                // 加载完成后的回调函数
                success: function (d) {
                    //  console.log(d);
                    //                选中节点，根据id筛选
                    treeSelect.checkNode('UnCode', 3);

                    // console.log($('#varProjectName').val());

                    //                获取zTree对象，可以调用zTree方法
                    var treeObj = treeSelect.zTree('UnCode');
                    console.log(treeObj);

                    //                刷新树结构
                    treeSelect.refresh('UnCode');
                }
            });

            //监听提交
            form.on('submit(submit)', function (data) {
                // data.field
                axios({
                    method: 'post',
                    url: '/User/AddEnterprise',
                    //headers: {
                    //    'content-type': 'application/x-www-form-urlencoded'
                    //},
                    data: data.field
                })
                    .then(function (response) {
                         console.log(response);
                        if (response.data.code == 200) {
                            javascript: history.go(-1);
                        } else {
                            alert(response.data.msg)
                        }

                    }).catch(function (error) {
                        console.log("添加失败!" + error);
                    });
                return false;
            });

        });
    </script>
}

<form class="layui-form layui-form-pane" asp-action="Edit">
    <div class="layui-form-item">
        <label class="layui-form-label">单位名称</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input w_545" autocomplete="off" lay-verify="required" asp-for="UserName">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">账户</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input w_545" autocomplete="off" lay-verify="required" asp-for="LoginName">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" class="layui-input w_545" autocomplete="off" lay-verify="required" asp-for="Password">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地区编码</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input w_545" autocomplete="off" lay-verify="required" asp-for="UnCode">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea asp-for="Remarks" style="width:545px;height:100px"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input class="layui-btn" type="button" style="width: 100px" lay-submit lay-filter="submit" value="立即提交" />
            <button type="reset" style="width: 100px" class="layui-btn layui-btn-primary">重置</button>
            <a style="width: 100px" class="layui-btn layui-btn-primary" asp-action="List">返回</a>
        </div>
    </div>
</form>

